home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-17 | 4.4 KB | 236 lines | [TEXT/KAHL] |
- /* This file takes care of the floating scores above Fuseballs */
- /* It basically implememts another set of 7 segment #'s, like VADrawNumber */
- /* but it is compatible with using on the pplaying field, VADrawNumber will */
- /* overdraw the playing field and leave holes when erased. (mz) */
-
- /* December 22,1992 © Mike Zimmerman */
-
-
- #include "VA.h"
- #include "Storm.h"
- #include <Math.h>
-
- #define STARTAGE 40
- #define MAXFLSCORES 20
-
- #define METHOD2
-
- extern Player Hero;
-
- typedef struct
- {
- int AGE;
- int score;
- int x1;
- int y1;
- int scale;
- } FloatingScore;
-
- #ifdef METHOD1
- char digits[]={ 1+2+4+8+16+32, /* 0 */
- 2+4, /* 1 */
- 1 +4+8 +32+64, /* 2 */
- 1+2+4+8 +64, /* 3 */
- 2+4 +16 +64, /* 4 */
- 1+2 +8+16 +64, /* 5 */
- 1+2 +8+16+32+64, /* 6 */
- 2+4+8, /* 7 */
- 1+2+4+8+16+32+64, /* 8 */
- 1+2+4+8+16 +64}; /* 9 */
- #endif
-
- int FSCount;
- int FSStart;
- FloatingScore *FLScores;
-
- #ifdef METHOD1
- void BottomSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x + 1,y);
- VASafeLineTo(x + VA.segmscale*3 -1,y); /* bottom segment */
- }
-
- void MiddleSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x + 1,y-VA.segmscale*2-2)
- VASafeLineTo(x + VA.segmscale*3 -1,y-VA.segmscale*2-2); /* middle segment */
- }
-
- void TopSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x + 1,y-VA.segmscale*4-4);
- VASafeLineTo(x + VA.segmscale*3 -1,y-VA.segmscale*4-4); /* top segment */
-
- }
-
- void LeftBtSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x,y-1);
- VASafeLineTo(x,y-VA.segmscale*2-2 + 1); /* left lower segment */
-
- }
- void LeftUpSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x,y-VA.segmscale*2-2-1);
- VASafeLineTo(x,y-VA.segmscale*4-4 + 1); /* left upper segment */
- }
-
- void RightBtSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x + VA.segmscale*3,y-1);
- VASafeLineTo(x + VA.segmscale*3,y-VA.segmscale*2-2 + 1); /* right lower segment */
-
- }
- void RightUpSeg(x,y)
- int x;
- int y;
- {
- VAMoveTo(x + VA.segmscale*3,y-VA.segmscale*2-2-1);
- VASafeLineTo(x + VA.segmscale*3,y-VA.segmscale*4-4 + 1); /* right upper segment */
- }
-
- void DrawScore(x,y,score)
- int x;
- int y;
- int score;
- {
- int digit;
- int i;
- int numlen;
- int curx;
- int mask;
-
-
- VA.color=3;
-
- VA.segmscale=(int)(Getfontscale()*3/4);
-
- numlen = (int) log10(score);
- for(i=0; i <= numlen; i++)
- {
- curx = x + (VA.segmscale*3+3)*i;
- VAMoveTo(curx,y);
- digit = (int)( score/pow(10,(numlen-i)) );
- score -= digit*pow(10,(numlen-i));
- mask = digits[digit];
- if (mask & 1)
- BottomSeg(curx,y);
- if (mask & 2)
- RightBtSeg(curx,y);
- if (mask & 4)
- RightUpSeg(curx,y);
- if (mask & 8)
- TopSeg(curx,y);
- if (mask & 16)
- LeftUpSeg(curx,y);
- if (mask & 32)
- LeftBtSeg(curx,y);
- if (mask & 64)
- MiddleSeg(curx,y);
- }
- }
-
- void UpdateFloatingScores()
- {
- int i,j;
-
- for(i = FSStart;i < ((FSCount+FSStart)%MAXFLSCORES) ; i++)
- {
- j=i%MAXFLSCORES;
- FLScores[j].AGE -= 1;
- if (FLScores[j].AGE == 0 || Hero.state == HeroFlying)
- /* Score expired, so remove it */
- {
- FLScores[j].AGE = 0;
- FSCount--;
- FSStart++;
- }
- else DrawScore(FLScores[j].x1,FLScores[j].y1,FLScores[j].score);
- }
- }
- #endif
-
-
- #ifdef METHOD2
- void DrawScore(x,y,score,scale)
- int x;
- int y;
- int score;
- int scale;
- {
- int numlen;
-
- VA.color=BG1;
- VA.segmscale=scale;
- VADrawNumber(score,x,y);
- }
-
- void UpdateFloatingScores()
- {
- int i,j;
-
- for(i = FSStart;i < ((FSCount+FSStart)%MAXFLSCORES) ; i++)
- {
- j=i%MAXFLSCORES;
- FLScores[j].AGE -= 1;
- if (FLScores[j].AGE == 0 || Hero.state == HeroFlying)
- /* Score expired, so remove it */
- {
- VA.color=-1;
- VA.segmscale=FLScores[j].scale;
- VADrawNumber(FLScores[j].score,FLScores[j].x1,FLScores[j].y1);
- FLScores[j].AGE = 0;
- FSCount--;
- FSStart++;
- VA.color=0;
- if (FSCount == 0)
- RedrawField();
- }
- }
- }
- #endif
-
- void AddFLScore(x,y,fscore) /* mz */
- int x;
- int y;
- int fscore;
- {
- FLScores[(FSCount+FSStart)%MAXFLSCORES].scale = (int)(Getfontscale());
- DrawScore(x,y,fscore,FLScores[(FSCount+FSStart)%MAXFLSCORES].scale);
- FLScores[(FSCount+FSStart)%MAXFLSCORES].AGE=STARTAGE;
- FLScores[(FSCount+FSStart)%MAXFLSCORES].score=fscore;
- FLScores[(FSCount+FSStart)%MAXFLSCORES].x1=x;
- FLScores[(FSCount+FSStart)%MAXFLSCORES].y1=y;
- FLScores[(FSCount+FSStart)%MAXFLSCORES].scale = (int)(Getfontscale());
- FSCount++;
- }
-
- void AllocFloatingScores()
- {
- FLScores=(FloatingScore *)NewPtr(sizeof(FloatingScore) * MAXFLSCORES);
- FSCount=0;
- }
-
- void InitFloatingScores()
- {
- register int i;
-
- for(i=0;i<MAXFLSCORES;i++)
- { FLScores[i].AGE=0;
- }
- FSCount=0;
- FSStart=0;
- }
-